<style>
    li img{max-width: 160px; max-height: 90px}
    .layui-input-block .layui-table td{border: none}
</style>
<div class="layui-form-item">
    <label class="layui-form-label">推广二维码</label>
    <div class="layui-input-block">
        <ul>
            <li>
                <table class="layui-table">
                    <tr>
                        <td width="10px">
                            <input type="hidden" id="ID_qrcode_img_url" name="qrcodeImg" value="#themeOption('qrcodeImg')">
                            <button type="button" class="layui-btn jfsa-select-image" id="ID_qrcode_img_upload" jfsa-input="ID_qrcode_img_url" jfsa-img="ID_qrcode_img_img">设置</button>
                        </td>
                        <td>
                            <div class="layui-form-mid layui-word-aux">图片高宽最好在96以内</div>
                        </td>
                    </tr>
                </table>
            </li>
            <li style="height: 90px">
                <img onclick="Jfsa.reviewImage(this);" src="#themeOption('qrcodeImg')" id="ID_qrcode_img_img">
            </li>
        </ul>
    </div>
</div>
<script>
    var $ = null, layer = null, element = null, form = null;
    layui.use(['jquery', 'layer', 'element', 'form'], function(){
        $ = layui.jquery, layer = layui.layer, element = layui.element, form= layui.form;
        console.log("load layui");
        #if(flashMsg)
                layer.msg("#(flashMsg)");
        #end

        $(".jfsa-select-image").on("click", function(){
            selectImage(this);
        });

        function selectImage(elem){### 打开选择图片的窗口，窗口中也可进行文件操作
            Jfsa.selectFile(layer, {
                elem : "#" + elem.id,
                type : 2,
                title : "选择图片",
                maxmin : false,
                area : [ '980px', '600px' ],
                closeBtn : 1,
                shadeClose : false,
                anim : 1,
                moveOut : false,
                resize : false,
                btn : [ '选择变色项', '取消' ],
                accept : "image",### 接受的文件类型
	            multiple : false,### 是否可选择多个文件
				updPath : '#(jfsa_upload_path)',### 上传路径，如果指定它，返回的res.folder将会是以它开头
				ctxPath : '#(ctx)',### 项目路径
	            done : function(res){
	                if(res.size > 0){
	                    var url = (res.folder == "" ? "/" : res.folder + "/") + res.files[0];
	                    var ipt = $(elem).attr("jfsa-input");
	                    if(ipt) $("#" + ipt).val(url);
	                    var img = $(elem).attr("jfsa-img");
	                    if(img) $("#" + img).attr("src", url);
	                }
	            },
	            error : function(res){
	            }
	        });
        }
    });
</script>